package com.bqjr.xms.controller;

import com.bqjr.xms.modle.ConsumerBeehiveUser;
import com.bqjr.xms.service.ConsumerBeehiveUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * Description: ConsumerBeehiveUserController.
 * @RestController 相当于 @ResponseBody ＋ @Controller合在一起的作用：表示Controller中的方法无法返回jsp页
 *
 * 这边的@RefreshScope注解不能少，否则即使调用/refresh，配置也不会刷新
 *
 * Created by XHZ on 2017/8/6.
 */
@RestController
@RequestMapping("/consumerBeehive")
@RefreshScope
public class ConsumerBeehiveUserController{
    @Value("${profile}")
    private String profile;
    @Autowired
    private ConsumerBeehiveUserService userConsumerService;

    @GetMapping("/hello")
    public String hello() {
        return this.profile;
    }

    @GetMapping("/{id}")
    public ConsumerBeehiveUser findById(@PathVariable Long id) {
        return this.userConsumerService.findById(id);
    }

    @GetMapping("/index")
    public ModelAndView index() {
        String host = "http://blog.didispace.com";
        // return模板文件的名称，对应src/main/resources/templates/index.html
        return new ModelAndView("index","msg",host);
    }

}
